<template>
  <view class="home">
    <!-- <u-text color="#000" size="15" bold text="客户信息"></u-text> -->
    <block v-for="(item,index) in messageList" :key="item.conversationID">
      <message-item :border="index == 0?false:true" :item="item"></message-item>
    </block>
   <!-- <block v-if="userInfo.user_type != 0">
      <u-text color="#000" size="15" bold text="经纪人信息"></u-text>
      <block v-for="(item,index) in messageList" :key="item.conversationID">
        <message-item :border="index == 0?false:true" :item="item"></message-item>
      </block>
    </block> -->
    <u-empty margin-top="50" v-if="!messageList.length"></u-empty>
  </view>
</template>

<script setup>
  import { onShow } from '@dcloudio/uni-app';
  import messageItem from './components/message-item.vue';
  import { ref } from 'vue';
  import { getCache } from '../../util/util';
  const userInfo = ref({})
  const messageList = ref([])
  onShow(() => {
    _initList()
    userInfo.value = getCache('userInfo')
    uni.hideTabBarRedDot({
      index:2,
    })
  })
  // 初始化列表
  const _initList = () => {
    uni.$chat.getConversationList().then(res => {
      messageList.value = res.data.conversationList
    console.log(res,messageList.value.length,!messageList.value.length)
    })
  }
</script>

<style lang="scss" scoped>
  .home {
    min-height: 100vh;
    background: #fff;
    padding: 24rpx;
  }
</style>